package wodegua.d2_demo;

public class Triangle {
    public static void main(String[] args) {
        star(4);
        star2(4);
    }

    public static void star(int number){
        /**
         *          *
         *        * * *
         *      * * * * *
         *    * * * * * * *
         */
        for (int i = 1; i <= number; i++) {
            for (int j = 1; j <= (number - i); j++) {
                System.out.print(" ");
            }
            for (int j = 1; j <= (2 *i - 1); j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public static void star2(int number){
        for (int i = 1; i <= number; i++) {
            for (int j = 1; j <= (number - i); j++) {
                System.out.print(" ");
            }
            for (int j = 1; j <= (2 *i - 1); j++) {
                System.out.print(j % 2 == 0 ? " " : "*");
            }
            System.out.println();
        }
    }
}
